package com.rentong.basic;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import javax.persistence.Transient;
import java.io.Serializable;

/**
 * @author ZXY
 * @ClassName: BasePage
 * @Description: 分页基类，对象通过继承实现分页参数传递
 * @date 2017/10/13 14:31
 */
public class BasePage implements Serializable {

    private static final long serialVersionUID = 7194322076680472135L;
    //第几页
    @Transient
    private Integer page;
    //每页多少数据
    @Transient
    private Integer rows;
    //排序字段
    @Transient
    private String sort;
    //升序 降序
    @Transient
    private String order;

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getRows() {
        return rows;
    }

    public void setRows(Integer rows) {
        this.rows = rows;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public String getOrder() {
        return order;
    }

    public void setOrder(String order) {
        this.order = order;
    }

    public static <T> Page<T> needPage(BasePage basePage) {
        return PageHelper.startPage(basePage.getPage(), basePage.getRows(), true);
    }

}
